import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编号',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '名称',
    align:"center",
    dataIndex: 'name',
    width: 200
   },
   {
    title: '简称',
    align:"center",
    dataIndex: 'shortName',
    width: 170
   },
   {
    title: '分类',
    align:"center",
    dataIndex: 'customerClass'
   },
   {
    title: '行业',
    align:"center",
    dataIndex: 'trade'
   },
   {
    title: '开户名',
    align:"center",
    dataIndex: 'accountName'
   },
   {
    title: '开户账号',
    align:"center",
    dataIndex: 'accountNo'
   },
   {
    title: '开户行',
    align:"center",
    dataIndex: 'accountBank'
   },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'contacts'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'mobile'
   },
   {
    title: '企业邮箱',
    align:"center",
    dataIndex: 'email'
   },
   {
    title: '启用门户',
    align:"center",
    dataIndex: 'enablePortal',
    customRender: ({ text }) => {
      return render.renderDict(text, 'enable_portal');
    },
   },
   {
    title: '关联账号',
    align:"center",
    dataIndex: 'associatedAccount'
   },
   {
    title: '办公地址',
    align:"center",
    dataIndex: 'officeAddress',
    width: 230
   },
   {
    title: '启用状态',
    align:"center",
    dataIndex: 'enableStatus',
    width: 100,
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'1'},{text:'否',value:'0'}])
     },
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '第三方编码',
    align:"center",
    dataIndex: 'thirdPartyCode'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "编号",
      field: 'code',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "名称",
      field: 'name',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "分类",
      field: 'customerClass',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "联系电话",
      field: 'mobile',
      component: 'Input',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'code',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编号!'},
          ];
     },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入名称!'},
          ];
     },
  },
  {
    label: '简称',
    field: 'shortName',
    component: 'Input',
  },
  {
    label: '分类',
    field: 'customerClass',
    component: 'Input',
    // dynamicRules: ({model,schema}) => {
    //       return [
    //              { required: true, message: '请输入分类!'},
    //       ];
    //  },
  },
  {
    label: '行业',
    field: 'trade',
    component: 'Input',
  },
  {
    label: '开户名',
    field: 'accountName',
    component: 'Input',
  },
  {
    label: '开户账号',
    field: 'accountNo',
    component: 'Input',
  },
  {
    label: '开户行',
    field: 'accountBank',
    component: 'Input',
  },
  {
    label: '联系人',
    field: 'contacts',
    component: 'Input',
    // dynamicRules: ({model,schema}) => {
    //       return [
    //              { required: true, message: '请输入联系人!'},
    //       ];
    //  },
  },
  {
    label: '联系电话',
    field: 'mobile',
    component: 'Input',
    rules: rules.rule('phone', false),
  },
  {
    label: '企业邮箱',
    field: 'email',
    component: 'Input',
    rules: rules.rule('email', false),
  },
  {
    label: '启用门户',
    field: 'enablePortal',
    component: 'JDictSelectTag',
    defaultValue: 1,
    componentProps:{
        dictCode:"enable_portal",
        stringToNumber: true,
     },
  },
  {
    label: '关联账号',
    field: 'associatedAccount',
    component: 'Input',
  },
  {
    label: '办公地址',
    field: 'officeAddress',
    component: 'Input',
  },
  {
    label: '启用状态',
    field: 'enableStatus',
    defaultValue: 1,
     component: 'JSwitch',
     componentProps:{
         options:[1,0]
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input'
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}